package srzy.data

import srzy.diameter._
import srzy.module.SendAction

class CdrStr {
  var stdFull: String = ""
  var stdCutted: String = ""
  var realFull: String = ""
  var realCutted: String = ""

  override def toString(): String = "stdFull:\n" + stdFull.mkString("\n") + "\n" +
    "stdCutted:\n" + stdCutted.mkString("\n") + "\n" +
    "realFull:\n" + realFull.mkString("\n") + "\n" +
    "realCutted:\n" + realCutted.mkString("\n")
}

class CaseInfo {
  var caseName: String = ""
  var casePath: String = ""
  var caseDesc: String = ""
  //  var caseType: String = ""
  var sessionId: String = ""
  //  var initShell: String = ""
  var stdReceFromSMMsg: List[String] = List[String]()
  var realReceFromSMMsg: List[String] = List[String]()

  var stdSendToSMMsg: List[String] = List[String]()
  var realSendToSMMsg: List[String] = List[String]()

  var receFromSMMsgLog: String = ""
  var sendToSMMsgLog: String = ""

  var sendDCCMsg: List[scala.xml.Node] = List.empty[scala.xml.Node]
  var actions: List[srzy.module.Action] = List.empty[srzy.module.Action]

  //  var stdReceDCCMsg: List[scala.xml.Node] = List.empty[scala.xml.Node]
  var stdReceDCCMsg: List[String] = List.empty[String]
  //  var realReceDCCMsg: List[scala.xml.Node] = List.empty[scala.xml.Node]
  var realReceDCCMsg: List[String] = List.empty[String]

  var stdFullCdrs: List[(String, String)] = List.empty[(String, String)]
  var stdCuttedCdrs: List[(String, String)] = List.empty[(String, String)]
  var realFullCdrs: List[(String, String)] = List.empty[(String, String)]
  var realCuttedCdrs: List[(String, String)] = List.empty[(String, String)]

  var dccCompResult: Boolean = true
  var cdrCompResult: Boolean = false
  //  var dbCompResult: Boolean = true
  //  var rbMsgCompResult: Boolean = false
  var receFromSMMsgCompResult: Boolean = false
  var sendToSMMsgCompResult: Boolean = false
  //  var caseResult: Boolean = true
  var errLog: String = ""

  override def toString(): String = {

    val sb = new StringBuffer
    sb.append("caseName:" + caseName + "\n")
    sb.append("caseDesc:" + caseDesc + "\n")
    //    sb.append("caseType:" + caseType + "\n")
    //    sb.append("initShell:" + initShell + "\n")
    sb.append("receRealDCCMsg:" + "\n" + realReceDCCMsg.mkString("\n--------\n") + "\n")
    sb.append("stdSendDCCMsgNum:" + "\n" + actions.filter(e => e match {
      case a: srzy.module.SendAction => true
      case a: srzy.module.Action => false
    }).size + "\n")

    sb.append("stdReceFromSMMsg:" + "\n" + stdReceFromSMMsg.mkString("\n") + "\n")
    sb.append("realReceFromSMMsg:" + "\n" + realReceFromSMMsg.mkString("\n") + "\n")
    sb.append({
      if (receFromSMMsgLog != "")
        "receFromSMMsgLog:" + "\n" + receFromSMMsgLog + "\n"
      else
        ""
    })
    sb.append("stdSendToSMMsg:" + "\n" + stdSendToSMMsg.mkString("\n") + "\n")
    sb.append("realSendToSMMsg:" + "\n" + realSendToSMMsg.mkString("\n") + "\n")
    sb.append("sendToSMMsgLog:" + "\n" + sendToSMMsgLog + "\n")
    //    sb.append({
    //      if (cdrInfo.stdFull.length + cdrInfo.stdCutted.length +
    //        cdrInfo.realFull.length + cdrInfo.realCutted.length > 0)
    //        "cdrInfo:" + "\n" + cdrInfo + "\n"
    //      else
    //        ""
    //    })

    sb.append("stdFullCdrs:" + "\n" + stdFullCdrs.map(e => e._1 + ":" + e._2).mkString("\n") + "\n")
    sb.append("stdCuttedCdrs:" + "\n" + stdCuttedCdrs.map(e => e._1 + ":" + e._2).mkString("\n") + "\n")
    sb.append("realFullCdrs:" + "\n" + realFullCdrs.map(e => e._1 + ":" + e._2).mkString("\n") + "\n")
    sb.append("realCuttedCdrs:" + "\n" + realCuttedCdrs.map(e => e._1 + ":" + e._2).mkString("\n") + "\n")

    sb.append("cdrCompResult:" + cdrCompResult + "\n")
    sb.append("receFromSMMsgCompResult:" + receFromSMMsgCompResult + "\n")
    sb.append("sendToSMMsgCompResult:" + sendToSMMsgCompResult + "\n")
    sb.append("caseResult:" + (dccCompResult & cdrCompResult &
      receFromSMMsgCompResult & sendToSMMsgCompResult) + " caseName:" + caseName + "\n")
    sb.append({
      if (errLog != "")
        "errLog:\n" + errLog
      else
        ""
    })
    sb.append("\n---------------------------------------\n")

    sb.toString().replace("\n\n", "\n")
    //    "caseName:" + caseName + "\n" +
    //      "caseDesc:" + caseDesc + "\n" +
    //      "caseType:" + caseType + "\n" +
    //      "initShell:" + initShell + "\n" +
    //      //      "sendDCCMsg:" + sendDCCMsg.mkString("\n--------\n") + "\n" +
    //      //      "stdReceDCCMsg:" + "\n" + stdReceDCCMsg.mkString("\n--------\n") + "\n" +
    //      "receRealDCCMsg:" + "\n" + realReceDCCMsg.mkString("\n--------\n") + "\n" +
    //      "stdReceFromSMMsg:" + "\n" + stdReceFromSMMsg.mkString("\n") + "\n" +
    //      "realReceFromSMMsg:" + "\n" + realReceFromSMMsg.mkString("\n") + "\n" +
    //      {
    //        if (receFromSMMsgLog != "")
    //          "receFromSMMsgLog:" + "\n" + receFromSMMsgLog + "\n"
    //        else
    //          ""
    //      } +
    //      "stdSendToSMMsg:" + "\n" + stdSendToSMMsg.mkString("\n") + "\n" +
    //      "realSendToSMMsg:" + "\n" + realSendToSMMsg.mkString("\n") + "\n" +
    //      "sendToSMMsgLog:" + "\n" + sendToSMMsgLog + "\n" +
    //      {
    //        if (cdrInfo.stdFull.length + cdrInfo.stdCutted.length +
    //          cdrInfo.realFull.length + cdrInfo.realCutted.length > 0)
    //          "cdrInfo:" + "\n" + cdrInfo + "\n"
    //        else
    //          ""
    //      } +
    //      //      "dccCompResult:" + dccCompResult + "\n" +
    //      "cdrCompResult:" + cdrCompResult + "\n" +
    //      //      "dbCompareResult:" + dbCompResult + "\n" +
    //      //      "rbMsgCompResult:" + rbMsgCompResult + "\n" +
    //      "receFromSMMsgCompResult:" + receFromSMMsgCompResult + "\n" +
    //      "sendToSMMsgCompResult:" + sendToSMMsgCompResult + "\n" +
    //      "caseResult:" + (dccCompResult & cdrCompResult &
    //        receFromSMMsgCompResult & sendToSMMsgCompResult) + " caseName:" + caseName + "\n" +
    //        (if (errLog != "") "errLog:\n" + errLog + "\n" else "") +
    //        "---------------------------------------"
  }
}